

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var show_color = "#f59057";



    //红绿灯初始化端口  
Blockly.Blocks.microbit_trafficlightsInit = {
    init:function(){
    this.setColour(show_color);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/27.Water  ljght Module.svg", 84, 42))
       .appendField(Blockly.Msg.MICROBIT_TRAFFICLIGHTSINIT)
       .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSRED)
       .appendField(new Blockly.FieldDropdown([
        ['P8', "pin8"],
        ['P15', "pin15"],
       ]),"red")
       .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSGREEN)
       .appendField(new Blockly.FieldDropdown([
        ['P0', "pin0"],
        ['P13', "pin13"],
       ]),"green")
       .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSYELLOW)
       .appendField(new Blockly.FieldDropdown([
        ['P1', "pin1"],
        ['P2', "pin2"],
       ]),"yellow")
       this.setPreviousStatement(true, null);
       this.setNextStatement(true, null);
       this.setTooltip('');
    }
};

    //红绿灯
Blockly.Blocks.microbit_trafficlights = {
    init:function(){
    this.setColour(show_color);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/27.Water  ljght Module.svg", 84, 42))
       .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSRED)
       .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.MICROBIT_BRIGHT, "True"],
        [Blockly.Msg.MICROBIT_EXTINCT, "False"],
      ]),"trafficlightsRed")
      .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSGREEN)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.MICROBIT_BRIGHT, "True"],
        [Blockly.Msg.MICROBIT_EXTINCT, "False"],
      ]),"trafficlightsGreen")
      .appendField(Blockly.Msg.MICROBIT_TRIFFICLIGHTSYELLOW)
       .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.MICROBIT_BRIGHT, "True"],
        [Blockly.Msg.MICROBIT_EXTINCT, "False"],
       ]),"trafficlightsYellow")
       this.appendValueInput("lightTime1", Number)
       .appendField(Blockly.Msg.MICROBIT_SHOWTIME)
    this.setPreviousStatement(true,null);
      this.setNextStatement(true,null);
    this.setTooltip('');
    }
    };

    return Blockly;
}

module.exports = SensorbitUnoBlocks;

